package com.book.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.aop.interceptor.PerformanceMonitorInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    /**
     * @Description: 插入时的填充策略
     * @Author: Mr.Zhang
     * @Date: 2021/1/21
     */
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setInsertFieldValByName("createtime", new Date(), metaObject);
        this.setInsertFieldValByName("backdate", new Date(), metaObject);
        this.setInsertFieldValByName("indentdate", new Date(), metaObject);
    }

    /**
     * @Description: 更新时的填充策略
     * @Author: Mr.Zhang
     * @Date: 2021/1/21
     */
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setUpdateFieldValByName("updatetime", new Date(), metaObject);
    }
}
